import 'package:get/get.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';

import 'state.dart';

class MsgLogic extends GetxController {
  final MsgState state = MsgState();

  @override
  void onInit() {
    state.rc = RefreshController();
    super.onInit();
  }

  void onRefresh() {
    state.pageIndex = 1;
    if (state.rc.isRefresh) {
      state.rc.refreshCompleted();
    }
  }

  void onLoading() {
    state.pageIndex++;
    if (state.rc.isLoading) {
      state.rc.loadComplete();
    }
  }

  @override
  void onClose() {
    state.rc.dispose();
    super.onClose();
  }
}
